<template>
	<view>
		<view class="nav-box">
			<view class="nav">
				<image class="nav-image" src="../../../static/images/icons/back.svg" @click="back"></image>
				<view class="nav-title">修改性别</view>
				<button class="nav-button" :disabled="true" style="opacity: 0;">保存</button>
			</view>
		</view>
		<radio-group @change="sexChange" class="card-box">
			<view class="item" v-for="item in sexGroup" :key="item">
				<view class="sex">{{item}}</view>
				<radio :value="item" :checked="item == sex"/>
			</view>
		</radio-group>
	</view>
</template>

<script>
	import {updateUser} from "../../../static/js/User.js"
	export default {
		data() {
			return {
				"flag":true,
				"sex":"",
				"sexGroup":["男","女","保密"]
			}
		},
		onShow() {
			this.userInfo = uni.getStorageSync("userInfo")
			this.sex = this.userInfo.sex
		},
		methods: {
			back(){
				uni.navigateBack({
					url: '/pages/user/editInfo'
				})
			},
			sexChange(e){
				this.sex = e.detail.value
				this.userInfo.sex = this.sex
				updateUser(this.userInfo).then(res=>{
					uni.setStorageSync("userInfo",this.userInfo)
					uni.navigateBack({url: '/pages/user/editInfo'})
				})
			},
		}
	}
</script>

<style>
	@import url("../../../static/css/base.css");
	.card-box{
		position: relative;
		background-color: #fff;
		margin: 0 20rpx;
		top: 180rpx;
		z-index: 30;
		border-radius: 20rpx;
	}
	.card-box .item{
		display: flex;
		justify-content: space-between;
		margin: 0 40rpx;
		padding: 20rpx 0;
		border-bottom: 1px solid #efefef;
	}
	
</style>
